#pragma once

#include <iostream>


#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)

#define CONV(v) (struct sockaddr *)(v)

enum 
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    LISTEN_ERR,
    ACCEPT_ERR,
    RECV_ERR
};


bool ParseOneLine( std::string& request_str,std::string* req_line,std::string sep)
{
    auto pos=request_str.find(sep);
    if(pos==std::string::npos)
        return false;
    *req_line=request_str.substr(0,pos);
    request_str.erase(0,pos+sep.size());
    return true;
}